/***********************************************************
 * Product Name: ExcelQuicker
 * Copyright (c)2005, Eunge
 * Author: Eunge
 * Web Site: www.eudev.net
 * Mail/MSN: eudev.net@yeah.net
 * ********************************************************/
using System;

namespace ExcelQuicker.Framework
{
	/// <summary>
	/// Comment class. Insert comment on a cell.
	/// </summary>
	[Serializable]
	public class EQComment: EQCell  	
	{
		private EQBool mVisible = EQBool.Default;
		private float mWidth;
		private float mHeight;
		

		/// <summary>
		/// Set/Get whether the area of comment is visible
		/// </summary>
		public bool Visible
		{
			get
			{
				return (this.mVisible==EQBool.True)?true:false;
			}
			set
			{
				this.mVisible = (value)?EQBool.True:EQBool.False;
			}
		}
		

		/// <summary>
		/// Set/Get the width of comment area
		/// </summary>
		public float Width
		{
			get
			{
				return this.mWidth;
			}
			set
			{
				this.mWidth = EQKit.CheckMeasure(value);
			}
		}

		/// <summary>
		/// Set/Get the height of comment area
		/// </summary>
		public float Height
		{
			get
			{
				return this.mHeight;
			}
			set
			{
				this.mHeight = EQKit.CheckMeasure(value);
			}
		}

		/// <summary>
		/// Initialize
		/// </summary>
		/// <param name="text">Comment</param>
		/// <param name="top">Row index of cell</param>
		/// <param name="left">Column index of cell</param>
		public EQComment(string text, int top, int left):base(text, top, left, true){}


		/// <summary>
		/// Output comment object to the excel docuemnt
		/// </summary>
		/// <param name="objWorksheet"></param>
		protected internal override void Output(Excel.Worksheet objWorksheet)
		{
			Excel.Range objRange = (Excel.Range)objWorksheet.Cells[this.Top, this.Left];

			this.DoBeforeOperationEvent(objRange);
			
			if(objRange.Comment == null)
				objRange.AddComment(this.Text);
			else
				objRange.Comment.Text(this.Text, this.Missing, this.Missing);

			objRange.Comment.Visible = this.Visible;

			if(this.Height>0)
				objRange.Comment.Shape.Height = this.Height;
			if(this.Width>0)
				objRange.Comment.Shape.Width = this.Width;

			this.DoAfterOperationEvent(objRange);
		}
	}
}
